package com.example.newsmanager.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.newsmanager.entity.Comment;
import com.example.newsmanager.entity.DTO.CommentDTO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author AAA
 * @since 2023-11-01
 */
public interface CommentMapper extends BaseMapper<Comment> {
    @Select("SELECT comment_id as commentId, parent_id as parentId, news_id as newsId, comment_content as commentContent, user_name as userName, comment_time as commentTime, user_avatar as userAvatar  FROM comment WHERE parent_id = #{parentId}")
    List<CommentDTO> findByParentId(Long parentId);

    @Select("SELECT comment_id as commentId, parent_id as parentId, news_id as newsId, comment_content as commentContent, user_name as userName, comment_time as commentTime, user_avatar as userAvatar  FROM comment WHERE parent_id = #{parentId} AND news_id = #{newsId} ")
    List<CommentDTO> findByNewsId(Long parentId, Long newsId);


}
